<?php
$db = Zend_Db_Table::getDefaultAdapter();
$profiler = $db->getProfiler();
if ($profiler->getEnabled() && $profiler->getTotalNumQueries() > 0) {
?>
    <div style='text-align:center'>
        <h2>Database Profiling Report</h2>
        <p>Total queries executed: <?php echo $profiler->getTotalNumQueries() ?></p>
        <p>Total elapsed time: <?php echo $profiler->getTotalElapsedSecs() ?></p>
    </div>
    <table class='spreadsheet' cellpadding='0' cellspacing='0' style='margin: 10px auto; text-align: left;'>
        <thead>
            <tr>
                <th style='text-align: right;'>#</th>
                <th style="padding-left: 10px;">Query</th>
                <th>Time</th>   
            </tr>
        </thead>
        <tbody>
<?php foreach ($profiler->getQueryProfiles() as $queryNumber => $query) { ?>
        <tr>
            <td style='text-align: right;'>(<?php echo $queryNumber + 1 ?>)</td>
            <td style='padding-left: 10px;'><?php echo $query->getQuery(); ?></td>
            <td><?php echo $query->getElapsedSecs(); ?></td>
        </tr>
<?php } ?>
    </tbody>
</table>
<?php } ?>